// This section of code here handles the displaying of the GradeGrid
// logo, alongside with the homepage link.
var LOCAL_INDEX_REGEX = /(.*index\.php.*|.*localhost\/gradegrid\/(?!.+)|.*localhost\/gradegrid\/\?{1}.+)/
var ONLINE_INDEX_REGEX = /(.*gradegrid\.skytreader\.net(?!.+)|.*gradegrid\.skytreader\.net\??[^(\\|\/)]+)/
var this_page = document.URL

var isIndex = (LOCAL_INDEX_REGEX.test(this_page)) || (ONLINE_INDEX_REGEX.test(this_page))

document.write("<div style='float: left;'>")
if(isIndex){
	document.write('<img src="' + jsdots + 'images/gradegrid2_large.png" alt="GradeGrid logo" />')
} else{
	document.write('<a href="' + jsdots + 'index.php"><img src="' + jsdots + 'images/gradegrid2_large.png" alt="GradeGrid logo" /></a>');
}
document.write("</div>")

// This section of code here handles the displaying of the navigation bar.
var NAV_LINKS = new Array("faq", "about", "signup")
var i = 0
var limit = NAV_LINKS.length

document.write("<div class='navbar'>")

// We have a little special case here for the user account.
// Destroys the elegance of the loop below :C

var account_regex = new RegExp(".+/useraccount/*.*")

if(account_regex.test(this_page)){
	document.write("<img src='" + jsdots + "images/account_gray.png' />")
} else{
	document.write("<a href='" + jsdots + "useraccount/'>")
	document.write("<img src='" + jsdots + "images/account.png' />")
	document.write("</a>")
}


while(i < limit){
	
	var thislink_regex = new RegExp(NAV_LINKS[i] + "(.php)?", "")
	
	if(thislink_regex.test(this_page)){
		document.write("<img src='" + jsdots + "images/" + NAV_LINKS[i] + "_gray.png' />")
	} else{
		document.write("<a href='" + jsdots + NAV_LINKS[i] + ".php'>")
		document.write("<img src='" + jsdots + "images/" + NAV_LINKS[i] + ".png' />")
		document.write("</a>")
	}
	
	i++
}

document.write("</div>")